package castle.defense.project;

/**
 * the physics point class operates in the abstract "meter" unit, has a simple conversion function for getting the position on the screen
 * @author Daniel Wasserman
 *
 */
public class PhysicsPoint {
	double x, y;
	public PhysicsPoint(double x, double y)
	{
		this.x = x;
		this.y = y;
	}
	
	public float getScreenX() {return PE.toScreenX(x);}
	public float getScreenY() {return PE.toScreenY(y);}
	
	public double getX() {return x;} 
	public double getY() {return y;}
	
	public double getDistance(PhysicsPoint o) {
		return Math.sqrt((x-o.x)*(x-o.x) + (y-o.y)*(y-o.y));
	}
	
	public void update(long milli, double speed, double angle)
	{
		//# of seconds that have elapse
		double seconds = milli / 1000.0;
		//delta x & y in abstract "meters"
		double deltaX = Math.cos(angle) * speed * seconds;
		double deltaY = Math.sin(angle) * speed * seconds;
		x+=deltaX;
		y+=deltaY;
	}
	
	public String toString()
	{
		return String.format("(%.2f, %.2f)", x, y);
	}
}
